package com.wx.gof.pattern.creational.builder;

import lombok.Data;

/**
 * @ClassName Computer
 * @Author wx
 * @Description 计算机
 * @Date 2018-12-03-22:00
 */
@Data
public class Computer {
    /**
     * 显示器
     */
    private String display;
    /**
     * 键盘
     */
    private String keyboard;
    /**
     * 处理器
     */
    private String processor;
    /**
     * cpu
     */
    private String  cpu;
    /**
     * 显卡
     */
    private String graphicsCard;

    public Computer(ComputerBuilder computerBuilder){
        this.display = computerBuilder.graphicsCard;
        this.keyboard = computerBuilder.keyboard;
        this.processor = computerBuilder.processor;
        this.cpu = computerBuilder.cpu;
        this.graphicsCard = computerBuilder.graphicsCard;
    }

    @Override
    public String toString() {
        return "Computer{" + "display='" + display + '\'' + ", keyboard='" + keyboard + '\'' + ", processor='" + processor + '\'' + ", cpu='" + cpu + '\'' + ", graphicsCard='" + graphicsCard + '\'' + '}';
    }

    /**
      * @Author wx
      * @Description 计算机建造器
      * @Date 2018-12-03
      */
    public static class ComputerBuilder {
         /**
          * 显示器
          */
         private String display;
         /**
          * 键盘
          */
         private String keyboard;
         /**
          * 处理器
          */
         private String processor;
         /**
          * cpu
          */
         private String  cpu;
         /**
          * 显卡
          */
         private String graphicsCard;

         public ComputerBuilder setDisplay(String display) {
             this.display = display;
             return this;
         }

         public ComputerBuilder setKeyboard(String keyboard) {
             this.keyboard = keyboard;
             return this;
         }

         public ComputerBuilder setProcessor(String processor) {
             this.processor = processor;
             return this;
         }

         public ComputerBuilder setCpu(String cpu) {
             this.cpu = cpu;
             return this;
         }

         public ComputerBuilder setGraphicsCard(String graphicsCard) {
             this.graphicsCard = graphicsCard;
             return this;
         }

         public Computer build(){
            return new Computer(this);
         }
     }

}
